/*
 * @Author: nccloud
 * @PageInfo: 卡片取消
 */
import { AREA, UISTATUS, FIELDS, DATASOURCECACHE } from '../../constance';
import { showCancelDialog } from '../../tool/messageUtil';
import { getCurrentLastId } from '../../tool/cacheDataManager';
import pageInfoClick from './pageInfoClick';

export default function(props) {
        showCancelDialog({
                beSureBtnClick: () => {
                        let status = props.getUrlParam('status');
                        let id = props.getUrlParam('id');
                        props.setUrlParam({ status: UISTATUS.browse });
                        if (status == UISTATUS.add) {
                                let pk = id ? id : getCurrentLastId(DATASOURCECACHE.dataSourceListCacheKey);
                                pageInfoClick.call(this, props, pk);
                                props.resMetaAfterPkorgEdit();
                        } else {
                                let pk = props.form.getFormItemsValue(AREA.cardFormId, FIELDS.pk_head_fields).value;
                                pageInfoClick.call(this, props, pk ? pk : id);
                        }
                }
        });
}
